package com.huawei.appmarket.service.appdetail.view.card;

import android.app.Activity;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import com.huawei.appgallery.jsonkit.api.JsonBean;
import com.huawei.appmarket.framework.widget.ArrowImageView;
import com.huawei.appmarket.framework.widget.FoldingTextView;
import com.huawei.appmarket.service.appdetail.bean.detail.DetailDescBean;
import java.util.LinkedHashMap;
import java.util.List;
import o.azb;
import o.dgh;
import o.dgm;
import o.dok;
import o.drl;
import o.drq;
import o.eqx;
import o.ewm.h;
import o.ewm.j;

public class DetailDescCard extends drl implements OnClickListener {
    protected FoldingTextView ʻ;
    protected ArrowImageView ʼ;
    protected ViewGroup ʽ;
    protected TextView ˊॱ;
    protected boolean ˋॱ;
    protected TextView ˏॱ;
    protected String ͺ;
    protected DetailDescBean ॱˊ;
    protected TextView ॱॱ;
    private LayoutInflater ᐝॱ;

    public DetailDescCard() {
        this.ˋॱ = false;
        this.ॱ = 303;
    }

    public View ˊ(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle) {
        this.ᐝॱ = layoutInflater;
        this.ˋॱ = false;
        this.ˊ = layoutInflater.inflate(h.ˋˊ, null);
        ॱˊ();
        this.ॱॱ = (TextView) this.ˊ.findViewById(j.ˏˌ);
        this.ʼ = (ArrowImageView) this.ˊ.findViewById(j.ˎꜟ);
        this.ʻ = (FoldingTextView) this.ˊ.findViewById(j.ˌᐝ);
        this.ʻ.setTextAlignment(5);
        return this.ˊ;
    }

    private void ॱˊ() {
        azb.ˎ(this.ˊ, j.ˏᐧ);
        azb.ˋ(this.ˊ, j.ˏˍ);
        azb.ॱ(this.ˊ, j.ˌˎ);
    }

    public boolean ˊ(List<JsonBean> list) {
        if (list == null || list.size() <= 0) {
            return false;
        }
        DetailDescBean detailDescBean = (DetailDescBean) list.get(0);
        if (detailDescBean == null) {
            return false;
        }
        this.ॱˊ = detailDescBean;
        if (!ᐝ()) {
            return false;
        }
        if (this.ʻ == null || TextUtils.isEmpty(detailDescBean.ॱ())) {
            return false;
        }
        ʻ();
        ʼ();
        return true;
    }

    protected boolean ᐝ() {
        if (this.ॱॱ == null || TextUtils.isEmpty(this.ॱˊ.ˊ())) {
            return false;
        }
        this.ॱॱ.setText(this.ॱˊ.ˊ());
        if (!TextUtils.isEmpty(this.ॱˊ.ꜟ())) {
            ImageView imageView = (ImageView) this.ˊ.findViewById(j.ˎˌ);
            imageView.setVisibility(0);
            eqx.ˎ(imageView, this.ॱˊ.ꜟ());
        }
        return true;
    }

    protected void ʻ() {
        List ꜞ = this.ॱˊ.ꜞ();
        List ꓸ = this.ॱˊ.ꓸ();
        if (ꜞ != null && !ꜞ.isEmpty() && ꓸ != null && !ꓸ.isEmpty() && ꜞ.size() == ꓸ.size()) {
            this.ʽ = (ViewGroup) this.ˊ.findViewById(j.ˍˎ);
            for (int i = 0; i < ꜞ.size(); i++) {
                if (!TextUtils.isEmpty((CharSequence) ꜞ.get(i))) {
                    ViewGroup viewGroup = (ViewGroup) this.ᐝॱ.inflate(h.ˉ, null);
                    azb.ˏ(viewGroup, j.ـʼ);
                    this.ˏॱ = (TextView) viewGroup.findViewById(j.ʼﾞ);
                    this.ˊॱ = (TextView) viewGroup.findViewById(j.ˎˍ);
                    this.ˏॱ.setText((CharSequence) ꓸ.get(i));
                    this.ˊॱ.setText((CharSequence) ꜞ.get(i));
                    this.ʽ.addView(viewGroup);
                }
            }
        }
    }

    protected void ʼ() {
        if (this.ॱˊ.ᶥ()) {
            this.ͺ = this.ॱˊ.ॱ();
            if (this.ॱˊ.ॱ().length() > this.ॱˊ.ㆍ()) {
                int ㆍ = this.ॱˊ.ㆍ();
                if (dok.ˎ(this.ˎ.ॱˋ())) {
                    ㆍ += ㆍ;
                }
                if (ㆍ < this.ॱˊ.ॱ().length()) {
                    this.ͺ = this.ॱˊ.ॱ().substring(0, ㆍ);
                    this.ͺ += "...";
                }
            }
            if (!(this.ͺ.equals(this.ॱˊ.ॱ()) && this.ʽ == null)) {
                ˊॱ();
                this.ʼ.setVisibility(0);
            }
            this.ʻ.setVisibility(0);
            this.ʻ.setText(this.ͺ);
            return;
        }
        this.ʻ.setText(this.ॱˊ.ॱ());
        this.ʼ.setVisibility(8);
    }

    public void onClick(View view) {
        ʽ();
        drq.ॱ(this, this.ॱˊ, 1);
        this.ˋॱ = !this.ˋॱ;
        if (this.ˋॱ) {
            this.ʻ.setText(this.ॱˊ.ॱ());
            this.ʻ.setVisibility(0);
            this.ʼ.setArrowUp(true);
            if (this.ˏ != null) {
                this.ˏ.ॱ(this.ˊ);
            }
            if (this.ʽ != null) {
                this.ʽ.setVisibility(0);
                return;
            }
            return;
        }
        this.ʻ.setText(this.ͺ);
        this.ʼ.setArrowUp(false);
        if (this.ʽ != null) {
            this.ʽ.setVisibility(8);
        }
    }

    protected void ʽ() {
        LinkedHashMap linkedHashMap = new LinkedHashMap();
        linkedHashMap.put("title", this.ॱˊ.ˊ());
        linkedHashMap.put("service_type", String.valueOf(dgm.ˎ((Activity) this.ʻ.getContext())));
        linkedHashMap.put("layoutid", ˎ());
        dgh.ˋ("detail_updateintro_click", linkedHashMap);
    }

    protected void ˊॱ() {
        this.ʻ.setOnClickListener(this);
        this.ʼ.setOnClickListener(this);
        if (this.ˏॱ != null) {
            this.ˏॱ.setOnClickListener(this);
        }
        if (this.ˊॱ != null) {
            this.ˊॱ.setOnClickListener(this);
        }
    }
}
